import { Action, Actor } from 'iflux2';
import { List } from 'immutable';

export default class IntegralSetting extends Actor {
  defaultState() {
    return {
      settingInfo: {},
      obtainTradePay: {},
      rewardRules: List(),
      integralObtainWorth:{},//积分比例 
    }
  }
  @Action('setting-init')
  setupInit(state, data) {
    return state.merge(data);
  }
  @Action('handle-setting')
  onBasicSetup(state, data) {
    return state.merge(data);
  }
  @Action('rule-update')
  onRuleUpdate(state, newRule) {
    return state.update('rewardRules', rules => rules.map(r => r.get("id") == newRule.get("id") ? newRule : r));
  }
  @Action('setting-update')
  onSettingUpdate(state, newSetting) {
    return state.update('settingInfo', setting => setting.merge(newSetting));
  }
}